import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)


const routes = [
	{
		path: "/", 
		redirect: "/yingyuan"
	},
	{
		path: '/yingyuan',
    name: 'yingyuan',
		component: () => import(/* webpackChunkName: "yingyuan" */ '../components/yingyuan/yingyuan.vue'),
		children:[
			{
				path: "/yingyuan", 
				redirect: "/yingyuan/body"
			},
			{
				path: '/yingyuan/body',
				name: 'yingyuanbody',
				component: () => import(/* webpackChunkName: "yingyuanbody" */ '../components/yingyuan/myBody.vue')
			},
			{
				path: '/yingyuan/body2',
				name: 'yingyuanbody2',
				component: () => import(/* webpackChunkName: "yingyuanbody2" */ '../components/yingyuan/myBody2.vue')
			},
			{
				path: '/yingyuan/body3',
				name: 'yingyuanbody3',
				component: () => import(/* webpackChunkName: "yingyuanbody3" */ '../components/yingyuan/myBody3.vue')
			},
			{
				path: '/yingyuan/body4',
				name: 'yingyuanbody4',
				component: () => import(/* webpackChunkName: "yingyuanbody3" */ '../components/yingyuan/myBody4.vue')
			}
		]
	},
  {
		path: '/item/:id',
		name:'item',
		component: () => import(/* webpackChunkName: "item" */ '../views/item.vue'),
	},
	{
		path:'/shiping',
		name:"shiping",
		component: () => import(/* webpackChunkName: "shiping" */ '../views/shipingHome.vue'),
		children:[
			{
				path:'/shiping',
				redirect: "/shiping/body"
			},{
				path:'/shiping/body',
				name:'shipingbody',
				component: () => import(/* webpackChunkName: "shiping" */ '../components/shiping/shipingbody1.vue'),
			}
		]
	},
	{
		path:'/My/:logintype',
		name:"My",
		meta: { "logtype":false },
		beforeEnter(to, from, next) {
			console.log(to.meta.logtype);
			if(to.meta.logtype!=false){
				next()
			}else{
				next("/login")
			}
		},
		component: () => import(/* webpackChunkName: "My" */ '../views/MyinfoHome.vue'),
	},
	{
		path:'/login',
		name:"login",
		component: () => import(/* webpackChunkName: "My" */ '../views/loginViews.vue'),
	},
	{
		path:'*',
		name:"404",
		component: () => import(/* webpackChunkName: "My" */ '../views/404.vue'),
	}
]

const router = new VueRouter({
  routes
})

// 登录权限 路由守卫
// router.beforeEach((to,from,next)=>{

// })

export default router
